package com.secret;

import java.security.MessageDigest;


public class Data
{
	
	public static String MD5(String data) {
	    if (data == null) {
	      return null;
	    }

	    byte[] tmp = rawMD5(data);
	    if (tmp == null) {
	      return null;
	    }

	    return HEX.toHex(tmp);
	  }

	  public static byte[] rawMD5(String data) {
	    if (data == null) {
	      return null;
	    }

	    byte[] md5 = (byte[])null;
	    try {
	      MessageDigest md = MessageDigest.getInstance("MD5");
	      md.update(data.getBytes("utf-8"));
	      md5 = md.digest();
	    } catch (Exception e) {
	      e.printStackTrace();
	      md5 = (byte[])null;
	    }
	    return md5;
	  }
	  
};